/* ====================================================================
 * (#)Header: HighInd.java
 * (#)Revision: 
 * (#)Date Created: Apr 9, 2013
 * (#)Created By: Karol Wozniak
 * ====================================================================
 *
 * Copyright (c) 2013 karolak .  All rights reserved.
 *
 * ====================================================================
 * 
 * The software application represented here is the sole property of 
 * karolak. Its unauthorized utilization is expressly prohibited.
 * 
 * ====================================================================
 */
package com.karolak.stock.indicator;

import java.util.Collections;
import java.util.List;

import com.karolak.stock.data.DataManager;

/**
 * <code>HighInd</code> is used to ....
 * 
 * @author <a href="mailto:kwozniak@hotmail.com">Karol Wozniak</a>
 */
public class HighInd extends Indicator {

	/**
	 * @param dataManager
	 * @param period
	 * @param input
	 */
	public HighInd(DataManager dataManager, int period, Indicator input) {
		super(dataManager, period, input);
		setName(String.format("%s%s%s", super.getName(), getInput().getName(), getPeriod()));
	}

	public double execute(double x) {
		List<Double> list = getDataManager().getData(getInput().getName(), getPeriod());
		if (list.isEmpty()) {
			return x;
		}
		Collections.sort(list);
		return list.get(list.size() - 1);
	}
}
